package com.cn.auth.model.vo;


import com.cn.auth.enums.ResponseCodeEnum;

/**
 * @Program: bm-officeAuto-desform
 * @Description: 响应类 - 后端接口专用
 * @Author: ZhongWenjuan
 * @Date: 2021-04-13 13:35
 **/
public class ResultBean<T> {
    private boolean isSuccess;
    private int responseCode;
    private String responseMsg;
    private T data;

    public static ResultBean createSuccess() {
        ResultBean result = new ResultBean();
        result.setResponseCode(ResponseCodeEnum.SC.getCode());
        result.setResponseMsg(ResponseCodeEnum.SC.getFMsg());
        result.setIsSuccess(Boolean.TRUE);
        return result;
    }

    public static ResultBean defaultFail() {
        ResultBean result = new ResultBean();
        result.setResponseCode(ResponseCodeEnum.FAIL2.getCode());
        result.setResponseMsg(ResponseCodeEnum.FAIL2.getFMsg());
        result.setIsSuccess(Boolean.FALSE);
        return result;
    }
    public static ResultBean createFail( ResponseCodeEnum responseCodeEnum) {
        ResultBean result = new ResultBean();
        result.setResponseCode(responseCodeEnum.getCode());
        result.setResponseMsg(responseCodeEnum.getFMsg());
        result.setIsSuccess(Boolean.FALSE);
        return result;
    }
    public static ResultBean createFail(int responseCode, String responseMsg) {
        ResultBean result = new ResultBean();
        result.setResponseCode(responseCode);
        result.setResponseMsg(responseMsg);
        result.setIsSuccess(Boolean.FALSE);
        return result;
    }

    public ResultBean() {

    }

    /**
     * 成功
     *
     * @param data
     */
    public ResultBean(T data) {
        this.isSuccess = Boolean.TRUE;
        this.responseCode = ResponseCodeEnum.SC.getCode();
        this.responseMsg = ResponseCodeEnum.SC.getFMsg();
        this.data = data;
    }

    public boolean getIsSuccess() {
        return isSuccess;
    }

    public void setIsSuccess(boolean success) {
        isSuccess = success;
    }

    public int getResponseCode() {
        return responseCode;
    }

    public void setResponseCode(int responseCode) {
        this.responseCode = responseCode;
    }

    public String getResponseMsg() {
        return responseMsg;
    }

    public void setResponseMsg(String responseMsg) {
        this.responseMsg = responseMsg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
